package com.alks.function.mapper;

import com.alks.entity.data.entity.*;
import com.alks.function.data.request.quotation.*;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Mapper
public interface QuotationTypesMapper extends BaseMapper<QuotationType> {
    List<QuotationType> quotationList(QuotationTypeRequest request);

    List<QuotationTypeDetail> quotationListDetail(QuotationTypeDetailRequest request);

    BigDecimal getTotalPrice(QuotationTypeDetailRequest request);

    List<Map> getArgument(QuotationTypeDetailRequest request);

    Integer updateQuotationTypeDetail(IQuotationDetailRequest request);

    List<Map> getYfStyleCostBase1();

    List<String> getYfStyleCostBase2();

    Integer updateYfStyleCostBase(List<Map> base1);

    Long quotationTotal(QuotationTypeRequest request);

    List<String> getQuotationCustoms();

    List<String> getQuotationSeasons();

    List<Quotation> getQuotations(GetQuotationRequest request);

    Long getQuotationsTotal(GetQuotationRequest request);

    Integer save(@Param("quotation") QuotationType quotationType,@Param("baseSize") String baseSize,@Param("midSize") String midSize);

    List<YfPhoto> getPhotoPath();

    Integer setPhotoPath(@Param("photo") YfPhoto photoPath);

    void setQuotationPhoto(@Param("photo") YfPhoto photo);

    List<String> selectFromStyle(Quotation quotation);

    void setCfg(Quotation quotation);

    List<ReAndDevelopCondition> getReAndDevelopCondition();

    List<BomStyle> getBomStyleList(ReAndDevelopRequest request);

    List<BomStyleMaterial> getBomStyleMaterial(ReAndDevelopRequest request);

    List<BomStyleDetail> bomStyleDetail(@Param("mtlNo") String mtlNo);

    Integer setBomStyleRemark(@Param("style") String style,@Param("color") String color,@Param("remark") String remark);

    @Select("SELECT TECH_PERSON FROM YF_STYLE WHERE TECH_PERSON IS NOT NULL GROUP BY TECH_PERSON ")
    List<String> getResearchTechPerson();

    @Select("SELECT SEASON FROM YF_STYLE WHERE SEASON IS NOT NULL GROUP BY SEASON")
    List<String> getResearchSeason();

    @Select("SELECT CUST_NO FROM YF_STYLE WHERE CUST_NO IS NOT NULL GROUP BY CUST_NO ORDER BY CUST_NO ")
    List<String> getResearchCustNo();

    List<StyleResearch> getStyleResearch(StyleResearchRequest request);

    Long getStyleResearchTotal(StyleResearchRequest request);

    @Select("SELECT MIDSOLE_SIZE,SOLE_SIZE,SIZE_NO,CUT_SIZE,LAST_SIZE,INSOLE_SIZE FROM YF_STYLE_SIZE WHERE STYLE_NO = #{styleNo} ORDER BY\n" +
            "CAST(MIDSOLE_SIZE AS DECIMAL(10,2)),CAST(SOLE_SIZE AS DECIMAL(10,2)),CAST(SIZE_NO AS DECIMAL(10,2)),CAST(CUT_SIZE AS DECIMAL(10,2)),CAST(LAST_SIZE AS DECIMAL(10,2)),CAST(INSOLE_SIZE AS DECIMAL(10,2))")
    List<StyleResearchCodeDetail> getStyleResearchCodeDetail(String styleNo);

    @Select("SELECT SEQ_NO,COLOR_CODE,STYLE_COLOR,ENG_STYLE_COLOR,SHORT_STYLE_COLOR,PHOTO_PATH FROM  YF_STYLE_COLOR_DETAIL WHERE STYLE_NO = #{styleNo} ORDER BY CAST(SEQ_NO AS DECIMAL(10,2))")
    List<StyleResearchColorDetail> getStyleResearchColorDetail(String styleNo);

    @Select("SELECT CAST(TYPE_NO AS DECIMAL(10,1)) TYPE_NO,LAST_MOLD,CUT_TOOL,SOLE_PART,MIDSOLE,INSOLE,ITEM_NAME,SIZE1,SIZE2 FROM YF_STYLE_TYPE WHERE STYLE_NO = #{styleNo} ORDER BY TYPE_NO")
    List<StyleResearchToolsDetail> getStyleResearchToolsDetail(String styleNo);

    @Select("SELECT CUSTOM FROM YF_STYLE_COST_HEAD WHERE CUSTOM IS NOT NULL GROUP BY CUSTOM")
    List<String> getQuotationBrands();

    @Select("SELECT SEASON FROM YF_STYLE_COST_HEAD WHERE SEASON IS NOT NULL GROUP BY SEASON")
    List<String> getQuotationConditionSeasons();

    List<PcStyleCraftRep> getPcStyleCraftHead(PcStyleCraftRequest request);

    Long getPcStyleCraftHeadTotal(PcStyleCraftRequest request);

    List<PcStyleProcessCraftRep> getPcStyleCraftDetail(@Param("style") String style,@Param("color") String color,@Param("flag")String flag);

    List<PcBomMaterialColorDetailRep> getPcBomStyleColor(PcBomColorRequest request);

    Long getPcBomStyleColorTotal(PcBomColorRequest request);

    List<PcBomStyleColorDetailRep> getPcBomStyleDetail(String mtlNo);

    @Delete("DELETE  FROM YF_STYLE_COST_HEAD WHERE STYLE = #{style} AND SLIP_NO = #{slip}")
    void deleteByStyleSlipNo(@Param("style") String style,@Param("slip") String slip);

    void updateQuotationCheck(QuotationTypeCheckRequest request);

    void updateUsdAndTypeName(@Param("request") UpdateQuotationRsbAndTypeRequest request);

    Map<String, Object> getDetailForStyle(ReAndDevelopRequest req);

    List<Map<String, Object>> getStyle(StyleResearchRequest request);

    @Select("select count(*) from YF_BOM_HEAD_NEW2 where style_no = #{styleNo} and style_color = #{styleColor}")
    Integer getByYfBomHead(@Param("styleNo") String styleNo, @Param("styleColor") String styleColor);

    List<Map<String, Object>> getStyleExcel(List<String> list);
}
